home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / i / internet / software / netstsr / icmp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-04  |  2.7 KB  |  78 lines

  1.  
  2. #ifndef _INET_ICMP
  3. #define _INET_ICMP
  4.  
  5.  
  6. #ifndef _INET_PKT
  7. #include "pktdrv.h"
  8. #endif
  9.  
  10. #ifndef _INET_IP
  11. #include "ip.h"
  12. #endif
  13.  
  14. #define MAXICMP    300
  15. #define ECHO_TIMEOUT    6
  16.                                 /* icmp_types */
  17. #define ICMP_ECHOREP    0        /* ICMP Echo reply */#define ICMP_DESTIN        3        /* Destination Unreachable */#define ICMP_SOURCEQ    4        /* Source quench */#define ICMP_REDIR        5        /* Redirect */#define ICMP_ECHOREQ    8        /* ICMP Echo request */#define ICMP_TIMEX        11        /* Time exceeded */#define ICMP_PARAM        12        /* Parameter problem */#define ICMP_TIMEREQ    13        /* Timestamp request */#define ICMP_TIMEREP    14#define ICMP_INFO        15        /* Information request */
  18. #define ICMP_SUBNETREQ    17        /* subnet mask request */
  19. #define ICMP_SUBNETREP    18        /* subnet mask reply   */
  20.  
  21. #define    ICMP_DSTNET        0        /* icmp codes */#define    ICMP_DSTHOST    1#define    ICMP_DSTPROT    2#define    ICMP_DSTPORT    3#define    ICMP_DSTFRAG    4#define    ICMP_DSTSRC        5
  22. #define REDIRTABLEN        10
  23.  
  24. struct redent
  25. {
  26.     INADDR    dst_inaddr;
  27.     INADDR    gw_inaddr;
  28. };
  29.  
  30. extern struct redent redtab[];
  31.  
  32. typedef struct
  33. {
  34.     u_char    type;                /* ICMP type field */
  35.     u_char    code;                /* ICMP code field */
  36.     u_short chksum;                /* checksum */
  37.     u_short    part1;
  38.     u_short part2;        /* depends on type and code */
  39. }ICMP;
  40.  
  41.  
  42.  
  43. struct ping 
  44. {                /* ICMP Echo request/reply header */    u_char    ptype;    u_char    pcode;    u_short pchksum;    u_short pid;    u_short pseq;};
  45.  
  46. #define    PGNOSND        0    /* Couldn't send pkt */#define    PGTMO        1    /* timedout */#define    PGBADDATA    2    /* rcved bad data back */#define    PGWAITING    3    /* waiting for rcpt of packet */#define    PGSUCCESS    4    /* success */
  47.  
  48. /* structure of an icmp destination unreachable packet */struct destun  
  49. {    u_char    dtype;    u_char    dcode;    u_short dchksum;    u_short dno1;    u_short dno2;    IP        dip;    char    ddata[8];};/* structure of an icmp time exceeded packet */struct timex  
  50. {    u_char    ttype;    u_char    tcode;    u_short tchksum;    u_short tno1;    u_short tno2;    IP        tip;    char    tdata[8];};/* structure of a timestamp reply */struct tstamp 
  51. {    u_char    ttype;    u_char    tcode;    u_short txsum;    u_short tid;    u_short tseq;    long    tstamp[3];};/* structure of an icmp redirect */struct redirect
  52. {    u_char    rdtype;    u_char    rdcode;    u_short rdchksum;    INADDR    rdgw;    IP        rdip;    char    rddata[8];};
  53. /* structure of netmask lookup */
  54.  
  55. struct netmask
  56. {    u_char    nmtype;    u_char    nmcode;    u_short nmchksum;
  57.     u_short nmid;
  58.     u_short    nmseq;    INADDR    nmmask;};
  59.  
  60. typedef struct
  61. {
  62.     ETH        et;
  63.     IP        ip;
  64.     ICMP    icmp;
  65.     char    icmp_data[MAXICMP];
  66. } ICMP_PACKET;
  67.  
  68. #define ICMP_PKTSIZE    (int)(sizeof(ETH)+sizeof(IP)+sizeof(ICMP))
  69.  
  70.  
  71.  
  72. int icmp_init(void);
  73. int icmp_handler(PACKET *,int,INADDR);
  74. int icmp_dstun(INADDR,IP *,int);
  75. int icmp_ping(INADDR,int);
  76.  
  77. #endif
  78.